<template>
  <div class="item-container">
    <h4 class="item-title">精品推荐</h4>
    <div class="items-wrap">
       <div class="item" @click="clickItem(item.id)" v-for="item in items" :key="item.id">
        <img class="item-pic" v-lazy="item.pic" alt="">
        <div class="item-info">
          <h5 class="name">{{item.name}}</h5>
          <p class="desc">
            {{ item.characteristic ? item.characteristic: '暂无描述' }}
          </p>
          <div class="action">
            <p class="price">￥{{item.minPrice}}</p>
            <van-icon @click.stop="clickCartIcon(item.id)" size="24" color="#ff734c" name="jiarugouwuche" class-prefix="icon"></van-icon>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    items: {
      type: Array,
      required: true
    }
  },
  methods: {
    clickCartIcon (id) {
      this.$emit('clickCartIcon', id)
    },
    clickItem (id) {
      this.$emit('clickItem', id)
    }
  }
}
</script>

<style lang="scss" scoped>
.item-container{
  .item-title{
    font-size: 18px;
    color: #333;
    line-height: 40px;
    text-align: center;
  }
  .items-wrap{
    padding:0 5px;
    .item{
      display: flex;
      border-radius: 8px;
      background-color: #fff;
      overflow: hidden;
      margin-top: 5px;
      img.item-pic{
        width: 4.5rem;
      }
      .item-info{
        flex:1;
        padding-left:8px;
        padding-right:15px;
        .name{
          color: #333;
          font-size: 16px;
          line-height: 40px;
        }
        .desc{
          color: #666;
          font-size: 14px;
          line-height: 20px;
          width: 4.5rem;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        .action{
          display: flex;
          align-items: center;
          justify-content: space-between;
          .price{
            color: #333;
            font-size: 16px;
          }
        }
      }
    }
  }
}
</style>
